package logic

import (
	"context"

	"activity/activityRpc/activityRpc"
	"activity/activityRpc/internal/svc"

	"activity/models/mysql"
	"github.com/zeromicro/go-zero/core/logx"
)

type ShowActivityLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowActivityLogic {
	return &ShowActivityLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowActivityLogic) ShowActivity(in *activityRpc.ShowActivityRequest) (*activityRpc.ShowActivityResponse, error) {
	// todo: add your logic here and delete this line

	activity := mysql.Activity{}
	mysql.DB.Where("id=?", in.Id).Find(&activity)

	return &activityRpc.ShowActivityResponse{
		Id:            int64(activity.ID),
		Title:         activity.Title,
		ActivityImage: activity.ActivityImage,
		Info:          activity.Info,
		UserId:        int64(activity.UserId),
	}, nil
}
